#include <iostream>
#include <cstdlib>
#include <cassert>
#include <string>
#include <sstream>
#include <time.h>

#include "Graph.h"
#include "affiche.h"

using namespace std;

static int iteration = 0;

static string trace_id() {
    int i = ++iteration;
    ostringstream buffer;
    buffer << i;
    return "./resultats/graphe_" + buffer.str();
}

extern void graph_print(Graph * g){
  string s = trace_id();
  string cmd1 = "dot -Tpng " + s + ".dot -o " + s + ".png";
  string cmd2 = "rm " + s + ".dot";
  string cmd3 = "eog " + s + ".png &";
  g->saveOnDotFile(s + ".dot");
  system(cmd1.c_str());
  system(cmd2.c_str());
  system(cmd3.c_str());
  usleep(500000);
}
